From 7550e5d3f98d7cfe4fb74750e5557b6a355ea3bb Mon Sep 17 00:00:00 2001 From: "kfraser@dhcp93.uk.xensource.com" Date: Fri, 30 Jun 2006 13:33:20 +0100 Subject: [PATCH] Revert 10521, 10526 and 10527. This completes reversion of ACM modifications to xm. Signed-off-by: Keir Fraser --- tools/python/xen/util/security.py | 102 ------------------ tools/python/xen/xend/server/blkif.py | 12 +-- tools/python/xen/xm/addlabel.py | 149 +++++--------------------- tools/python/xen/xm/create.py | 59 +--------- tools/python/xen/xm/dry-run.py | 95 ---------------- tools/python/xen/xm/getlabel.py | 134 ----------------------- tools/python/xen/xm/main.py | 28 +---- tools/python/xen/xm/resources.py | 70 ------------ tools/python/xen/xm/rmlabel.py | 134 ----------------------- 9 files changed, 33 insertions(+), 750 deletions(-) delete mode 100644 tools/python/xen/xm/dry-run.py delete mode 100644 tools/python/xen/xm/getlabel.py delete mode 100644 tools/python/xen/xm/resources.py delete mode 100644 tools/python/xen/xm/rmlabel.py diff --git a/tools/python/xen/util/security.py b/tools/python/xen/util/security.py index df970f355e..f778cbc1fe 100644 --- a/tools/python/xen/util/security.py +++ b/tools/python/xen/util/security.py @@ -14,7 +14,6 @@ #============================================================================ # Copyright (C) 2006 International Business Machines Corp. # Author: Reiner Sailer -# Author: Bryan D. Payne #============================================================================ import commands @@ -22,14 +21,11 @@ import logging import sys, os, string, re import traceback import shutil -#from xml.marshal import generic from xen.lowlevel import acm from xen.xend import sxp -from xen.xend.XendLogging import log #global directories and tools for security management policy_dir_prefix = "/etc/xen/acm-security/policies" -res_label_filename = policy_dir_prefix + "/resource_labels" boot_filename = "/boot/grub/menu.lst" xensec_xml2bin = "/usr/sbin/xensec_xml2bin" xensec_tool = "/usr/sbin/xensec_tool" @@ -534,101 +530,3 @@ def list_labels(policy_name, condition): if label not in labels: labels.append(label) return labels - - -def get_res_label(resource): - """Returns resource label information (label, policy) if it exists. - Otherwise returns null label and policy. - """ - def default_res_label(): - ssidref = NULL_SSIDREF - if on(): - label = ssidref2label(ssidref) - else: - label = None - return (label, 'NULL') - - (label, policy) = default_res_label() - - # load the resource label file - configfile = res_label_filename - if not os.path.isfile(configfile): - log.info("Resource label file not found.") - return default_res_label() -# -# Commented out pending replacement for xml.marshal.generic -# -# fd = open(configfile, "rb") -# res_label_cache = generic.load(fd) -# fd.close() - -# # find the resource information -# if res_label_cache.has_key(resource): -# (policy, label) = res_label_cache[resource] - - return (label, policy) - - -def get_res_security_details(resource): - """Returns the (label, ssidref, policy) associated with a given - resource from the global resource label file. - """ - def default_security_details(): - ssidref = NULL_SSIDREF - if on(): - label = ssidref2label(ssidref) - else: - label = None - policy = active_policy - return (label, ssidref, policy) - - (label, ssidref, policy) = default_security_details() - - # find the entry associated with this resource - (label, policy) = get_res_label(resource) - if policy == 'NULL': - log.info("Resource label for "+resource+" not in file, using DEFAULT.") - return default_security_details() - - # is this resource label for the running policy? - if policy == active_policy: - ssidref = label2ssidref(label, policy, 'res') - else: - log.info("Resource label not for active policy, using DEFAULT.") - return default_security_details() - - return (label, ssidref, policy) - - -def res_security_check(resource, domain_label): - """Checks if the given resource can be used by the given domain - label. Returns 1 if the resource can be used, otherwise 0. - """ - rtnval = 1 - - # if security is on, ask the hypervisor for a decision - if on(): - (label, ssidref, policy) = get_res_security_details(resource) - domac = ['access_control'] - domac.append(['policy', active_policy]) - domac.append(['label', domain_label]) - domac.append(['type', 'dom']) - decision = get_decision(domac, ['ssidref', str(ssidref)]) - - # provide descriptive error messages - if decision == 'DENIED': - if label == ssidref2label(NULL_SSIDREF): - raise ACMError("Resource '"+resource+"' is not labeled") - rtnval = 0 - else: - raise ACMError("Permission denied for resource '"+resource+"' because label '"+label+"' is not allowed") - rtnval = 0 - - # security is off, make sure resource isn't labeled - else: - (label, policy) = get_res_label(resource) - if policy != 'NULL': - raise ACMError("Security is off, but '"+resource+"' is labeled") - rtnval = 0 - - return rtnval diff --git a/tools/python/xen/xend/server/blkif.py b/tools/python/xen/xend/server/blkif.py index 986d065be9..02cd4f26f7 100644 --- a/tools/python/xen/xend/server/blkif.py +++ b/tools/python/xen/xend/server/blkif.py @@ -21,7 +21,6 @@ import re import string from xen.util import blkif -from xen.util import security from xen.xend import sxp from xen.xend.XendError import VmError @@ -41,22 +40,15 @@ class BlkifController(DevController): def getDeviceDetails(self, config): """@see DevController.getDeviceDetails""" - uname = sxp.child_value(config, 'uname') dev = sxp.child_value(config, 'dev') - (typ, params) = string.split(uname, ':', 1) + (typ, params) = string.split(sxp.child_value(config, 'uname'), ':', 1) back = { 'dev' : dev, 'type' : typ, 'params' : params, 'mode' : sxp.child_value(config, 'mode', 'r') - } - - if security.on(): - (label, ssidref, policy) = security.get_res_security_details(uname) - back.update({'acm_label' : label, - 'acm_ssidref': str(ssidref), - 'acm_policy' : policy}) + } if 'ioemu:' in dev: (dummy, dev1) = string.split(dev, ':', 1) diff --git a/tools/python/xen/xm/addlabel.py b/tools/python/xen/xm/addlabel.py index e3966c9f59..57b0f79691 100644 --- a/tools/python/xen/xm/addlabel.py +++ b/tools/python/xen/xm/addlabel.py @@ -14,156 +14,61 @@ #============================================================================ # Copyright (C) 2006 International Business Machines Corp. # Author: Reiner Sailer -# Author: Bryan D. Payne #============================================================================ -"""Labeling a domain configuration file or a resoruce. +"""Labeling a domain configuration file. """ import sys, os -import string import traceback -#from xml.marshal import generic -from xen.util import security -def usage(): - print "\nUsage: xm addlabel